package org.tlipoca.smarticlelike.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.genntii.smdomain.entity.ArticleLike;

@Mapper
public interface ArticleLikeMapper extends BaseMapper<ArticleLike> {
    
    @Select("select * from Article_Like where user_id = #{userId} and article_id = #{articleId}")
    ArticleLike getArticleLike(@Param("userId")Long userId,@Param("articleId")Long articleId);

    @Select("select count(*) from Article_Like where `like` = 1 and article_id = #{articleId}")
    Integer getLike(@Param("articleId") Long articleId);

    @Select("select count(*) from Article_Like where `like` = 0 and article_id = #{articleId}")
    Integer getDislike(@Param("articleId") Long articleId);

    @Select("select `like` from Article_Like where user_id = #{userId} and article_id = #{articleId}")
    Byte articleLikeExists(@Param("userId") Long userId, @Param("articleId") Long articleId);

    @Delete("delete from Article_Like where article_id = #{articleId} and user_id = #{userId}")
    void delArticleLike(@Param("articleId") Long articleId, @Param("userId")Long userId);
}
